package com.lmoumou.lib_comment

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter

/**
 * 作者：Lmoumou
 * 时间：2020/7/21 09:55
 *
 * 常用的ViewPager2适配器
 */
class CommentPagerAdapter : FragmentStateAdapter {
    constructor(
        fragment: Fragment,
        dataList: MutableList<Fragment>
    ) : super(fragment) {
        this.dataList = dataList
    }

    constructor(
        fragmentActivity: FragmentActivity,
        dataList: MutableList<Fragment>
    ) : super(fragmentActivity) {
        this.dataList = dataList
    }

    private var dataList: MutableList<Fragment>

    override fun getItemCount(): Int = dataList.size

    override fun createFragment(position: Int): Fragment = dataList[position]
}